home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq15.zip
/
JOINCONF.SLT
< prev
next >
Wrap
Text File
|
1990-12-20
|
10KB
|
295 lines
//-----------------------------------------------------------
// JOINCONF.SLT Join Conference.
//
// Note: Lines commented out with //!! are not used in this script,
// but in other, related ones. Please don't delete them; they may
// become useful later.
//-----------------------------------------------------------
// Author: Inge Vabekk
// Hamangskogen 108
// N-1300 SANDVIKA
// NORWAY
str bbs_type [32] // BBS type.
,PrevConf [20]="" // Previous conference.
,NextConf [20]="" // Next conference.
,command [10] // Command prompt.
,temp [4] // Temporary for short strings.
// For the Global storage:
,global []="GLOBAL" // Global script.
,bbstype []="BTYPE" // BBS type.
,conf []="CONF" // Current conference
,prompt []="PROMPT" // Current command prompt.
;
int tol = 200 // No activity for 20 sec.
,stat, tmark // makes script time out.
,mbbs, pcb, rbbs, opus, fido, crcs
,PCBver // PCBoard version.
;
//-----------------------------------------------------------
// Script starts here.
//-----------------------------------------------------------
main (str NewConf)
{
int c, i, j, ercnt, switched
,yes, ent, par, con, com, co, y;
str Sline [80]
,pre [4]
,post [4]
,end [4]
,ans [4]
;
NextConf = NewConf; // Use local, since it may
// be changed.
// Only if online.
if (!carrier())
{ failtone();
status_wind ("THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
return (-1);
}
read (bbstype,bbs_type); // Get BBS type.
read (conf,PrevConf); // Get previous conference.
read (prompt,command); // Get command prompt.
mbbs = pcb = rbbs = opus = fido = crcs = 0;
if (bbs_type == "MBBS") mbbs = 1;
else if (bbs_type == "PCB") pcb = 1;
else if (bbs_type == "RBBS") rbbs = 1;
else if (bbs_type == "OPUS") opus = 1;
else if (bbs_type == "FIDO") fido = 1;
else if (bbs_type == "CRCS") crcs = 1;
else
{ wrongBBS(); // Don't know how to do it!
return (-1);
}
if (mbbs)
{ pre = "("; // Define the delimiters
post = ")"; // for the conference
end = "Q^M"; // name.
}
else if (pcb)
{ pre = "t) ";
post = " (";
end = "^M";
}
else if (rbbs)
{ pre = "";
post = " Co";
end = "^M";
}
co = strlen(pre); // Length of prefix.
y=gety();
if (rbbs)
{ --y; // RBBS:
if (y<0) y=0; // Conf. name on previous line.
}
vgetchrs(0,y,Sline,0,80); // Get command line from screen.
if (pcb) // PCBoard: Do some extra checks
{ if (strposi(PrevConf,"Main",0)==0 // for Main Board.
|| strposi(Sline,"Main Boa",0) > 0)
{ PrevConf = "Main Board"; // Set Main Board.
write (conf,PrevConf);
}
}
if (strlen(PrevConf) < 1) do // Have to find which conference
{ j = -1;
if (rbbs) // RBBS: Conference name
i = 0; // at beginning of line.
else
{ i = strposi(Sline,pre,0); // Find start byte.
if (i < 0)
{ i = strposi(Sline,"[",0); // Not found: Try "[".
if (i >= 0) // Is this the old format?
{ co = 1; // Yepp.
pre = "["; // Starts with a left bracket,
post = "]"; // ends with a right bracket.
}
i = i+co; // Proceed to conference name.
}
}
j = strposi (Sline,post,i); // Find end byte.
j = j-i; // Find the length.
if (j>0)
substr (Sline,i,j,PrevConf); // Conference found!
else
cputs (end); // Not found: Back to Main.
flush();
} while (j < 1);
// Previous conference known.
for (i=0; subchr(NextConf,i)==' ';++i) // Find first non-space.
; // Find end of line.
for (j=strlen(NextConf)-1; subchr(NextConf,j)==' ' ;--j)
setchr(NextConf,j,0); // Trim spaces from end of line.
if (i > 0) // Move it down to the
subchrs (NextConf,i,j,NextConf); // beginning of the line.
ercnt = switched = 0;
if (pcb)
{ if (strposi(NextConf,"Main",0) >= 0)
NextConf = "Main Board"; // Only one legal name
if (strposi(PrevConf,"Main",0) >= 0) // for Main Board.
PrevConf = "Main Board";
}
if (strposi(PrevConf,NextConf,0)==0) // Same conference?
return (0);
while (!switched && ercnt < 3) // Until conference changed:
{ ++ercnt;
flush(); // Eat all input, then
if (pcb && strposi(NextConf,"Main Board",0)==0)
cputs("A"); // Abandon Main Board.
else
{ cputs("J "); // join the conference.
cputs(NextConf);
}
ans = ""; // Next answer.
con = track(NextConf,1); // Check conference name.
if (pcb)
{ ent = track("(Enter)=",0);
par = track("left)",0); // ...minutes left
com = track(command,0);
}
else
{ par = ent = -948; // Not used for MBBS.
if (mbbs)
com = track(command,0);
else if (rbbs)
{ com = track("V,W,X>?",0);
ans = "n^M"; // Browse conference without
ent = track("Y,[N])?",0); // permanently joining (Y,[N])?
switched = 1;
}
}
cputs("^M");
tmark = timer_start (tol); // Just 20 sec. time-out.
while ((stat=trig()) > 0) // Wait for Command.
{ if (stat == ent)
{ if (pcb) // PCBoard:
{ terminal();
y=gety();
vgetchrs(0,y,Sline,0,80); // Get command line from screen.
if (strpos (Sline,"Mail Com") >=0)
ans = "qu^M"; // .... Main Board (0) Mail Command: (Enter)='xx...
else
ans = "n^M"; // Scan since last read?
} // Scan for personal mail?
cputs (ans); // Send answer.
}
else if (stat == par) // (Quit from mail command)
++ercnt; // ...minutes left)
else if (stat == com) // Command:
{ if (switched) // Check switch. If non-zero
write (conf,NextConf); // we're in this conference.
break;
}
else if (stat == con) // Conference name?
switched = 1; // We've switched.
}
track_free(0); // Stop all tracking.
} // Loops if unsuccesful.
timer_free(0);
if (!switched)
{ failtone();
prints ("JOIN CONFERENCE FAILED!");
}
if (!carrier()) switched = -1;
return (switched);
}
//-----------------------------------------------------------
// Wrong BBS type.
//-----------------------------------------------------------
wrongBBS()
{
str help[32];
failtone(); // Alarm.
help = "Illegal BBS type (or not found): ";
strcat (help,bbs_type);
strcat (help,"!");
status_wind (help,20); // Display message for 2 sec.
}
//-----------------------------------------------------------
// Flush incomi